home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / nivb / dirdir.frm < prev    next >
Text File  |  1995-05-07  |  8KB  |  267 lines

  1. VERSION 2.00
  2. Begin Form DirDirForm 
  3.    Caption         =   "Directory Services Test (Directory APIs)"
  4.    ClientHeight    =   3450
  5.    ClientLeft      =   1365
  6.    ClientTop       =   1665
  7.    ClientWidth     =   4905
  8.    Height          =   3855
  9.    Left            =   1305
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3450
  12.    ScaleWidth      =   4905
  13.    Top             =   1320
  14.    Width           =   5025
  15.    Begin ListBox TrusteeList 
  16.       Height          =   1005
  17.       Left            =   240
  18.       TabIndex        =   7
  19.       Top             =   1920
  20.       Width           =   4575
  21.    End
  22.    Begin CommandButton OKButton 
  23.       Caption         =   "&OK"
  24.       Height          =   375
  25.       Left            =   2040
  26.       TabIndex        =   0
  27.       Top             =   3000
  28.       Width           =   975
  29.    End
  30.    Begin Label EffectiveRightsLabel 
  31.       Height          =   255
  32.       Left            =   1680
  33.       TabIndex        =   10
  34.       Top             =   1440
  35.       Width           =   2655
  36.    End
  37.    Begin Label Label5 
  38.       Alignment       =   1  'Right Justify
  39.       Caption         =   "Your effective rights:"
  40.       Height          =   495
  41.       Left            =   120
  42.       TabIndex        =   9
  43.       Top             =   1200
  44.       Width           =   1455
  45.    End
  46.    Begin Label Label4 
  47.       Alignment       =   1  'Right Justify
  48.       Caption         =   "Trustees:"
  49.       Height          =   255
  50.       Left            =   240
  51.       TabIndex        =   8
  52.       Top             =   1680
  53.       Width           =   855
  54.    End
  55.    Begin Label CreatedLabel 
  56.       Height          =   255
  57.       Left            =   1680
  58.       TabIndex        =   6
  59.       Top             =   960
  60.       Width           =   1695
  61.    End
  62.    Begin Label OwnerLabel 
  63.       Height          =   255
  64.       Left            =   1680
  65.       TabIndex        =   5
  66.       Top             =   720
  67.       Width           =   2655
  68.    End
  69.    Begin Label Label3 
  70.       Alignment       =   1  'Right Justify
  71.       Caption         =   "Created:"
  72.       Height          =   255
  73.       Left            =   720
  74.       TabIndex        =   4
  75.       Top             =   960
  76.       Width           =   855
  77.    End
  78.    Begin Label Label2 
  79.       Alignment       =   1  'Right Justify
  80.       Caption         =   "Owner:"
  81.       Height          =   255
  82.       Left            =   960
  83.       TabIndex        =   3
  84.       Top             =   720
  85.       Width           =   615
  86.    End
  87.    Begin Label DirPathLabel 
  88.       Height          =   255
  89.       Left            =   720
  90.       TabIndex        =   2
  91.       Top             =   360
  92.       Width           =   5055
  93.    End
  94.    Begin Label Label1 
  95.       Caption         =   "Information for directory:"
  96.       Height          =   255
  97.       Left            =   240
  98.       TabIndex        =   1
  99.       Top             =   120
  100.       Width           =   2175
  101.    End
  102. End
  103.  
  104. Sub Form_Load ()
  105.     Dim dirEntry As NWDIR_ENTRY
  106.     Dim trustees3x As TRUSTEE_BUFFER_3X
  107.     Dim trustees2x As TRUSTEE_BUFFER_2X
  108.  
  109.     server$ = String$(48, 0)
  110.     volume$ = String$(16, 0)
  111.     dirs$ = String$(255, 0)
  112.  
  113.     ccode% = ParsePath(dirPath$, server$, volume$, dirs$)
  114.     
  115.     volume$ = Left$(volume$, InStr(volume$, Chr$(0)) - 1)
  116.     dirs$ = Left$(dirs$, InStr(dirs$, Chr$(0)) - 1)
  117.     dirPath$ = volume$ + ":/" + dirs$
  118.     
  119.     connID% = GetDefaultConnectionID()
  120.  
  121.     ccode% = AllocTemporaryDirectoryHandle(0, dirPath$, Asc("["), handle%, mask%)
  122.  
  123.     If (ccode% <> SUCCESSFUL) Then
  124.         MsgBox "Unable to allocate directory handle", MB_OK, "Error"
  125.     Else
  126.         ccode% = GetDirEntry(connID%, handle%, dirEntry)
  127.         If (ccode% <> SUCCESSFUL) Then
  128.             MsgBox "Unable to get directory information", MB_OK, "Error"
  129.         Else
  130.             oName$ = String$(48, 0)
  131.  
  132.             ccode% = GetBinderyObjectname(dirEntry.ownerID, oName$, ownerType%)
  133.             If (ccode% = SUCCESSFUL) Then
  134.                 OwnerLabel.Caption = oName$
  135.             Else
  136.                 OwnerLabel.Caption = "Unknown User"
  137.             End If
  138.  
  139.             DirPathLabel = dirPath$
  140.             CreatedLabel.Caption = GetDate$(dirEntry.creationDate, dirEntry.creationTime)
  141.  
  142.             sequence% = 0
  143.             dirName$ = String$(16, 0)
  144.             tRights$ = String$(5, 0)
  145.             
  146.             'Would get the rights mask from the trustee buffer,
  147.             '   but there is a bug in the v1.30 NWNETAPI.DLL, and
  148.             '   ScanEntryForTrustees doesn't copy the rights mask
  149.             '   to the buffer correctly
  150.             Do
  151.                 ver3x% = IsV3Supported(connID%)
  152.                 If (ver3x% = 1) Then
  153.                     ccode% = ScanEntryForTrustees(connID%, 0, dirPath$, trustees3x, sequence%, numTrusteeEntries)
  154.                     If (ccode% = SUCCESSFUL) Then
  155.                         sequence% = sequence% + 1
  156.                         For i = 0 To (Asc(trustees3x.numEntriesReturned) - 1)
  157.                             gotName% = GetBinderyObjectname(trustees3x.oID(i), oName$, oType%)
  158.                             If (gotName% <> 0) Then oName$ = "Unknown User"
  159.                             TrusteeList.AddItem oName$
  160.                         Next i
  161.                     End If
  162.                 Else
  163.                     ccode% = ScanEntryForTrustees(connID%, 0, dirPath$, trustees2x, sequence%, numTrusteeEntries)
  164.                     If (ccode% = SUCCESSFUL) Then
  165.                         sequence% = sequence% + 1
  166.                         For i = 0 To 4
  167.                             If (trustees2x.oID(i) = 0) Then Exit For
  168.                             gotName% = GetBinderyObjectname(trustees2x.oID(i), oName$, oType%)
  169.                             If (gotName% <> 0) Then oName$ = "Unknown User"
  170.                             TrusteeList.AddItem oName$
  171.                         Next i
  172.                     End If
  173.                 End If
  174.             Loop Until (ccode% <> SUCCESSFUL)
  175.         End If
  176.         
  177.         ccode% = GetEffectiveRights(connID%, 0, dirPath$, rights%)
  178.         If (ccode% = SUCCESSFUL) Then
  179.             EffectiveRightsLabel.Caption = GetRights(rights%)
  180.         Else
  181.             EffectiveRightsLabel.Caption = "Unable to obtain"
  182.         End If
  183.  
  184.         ccode% = DeallocateDirectoryHandle(handle%)
  185.         If (ccode% <> SUCCESSFUL) Then
  186.             MsgBox "Unable to deallocate directory handle", MB_OK, "Error"
  187.         End If
  188.     End If
  189. End Sub
  190.  
  191. Function GetRights (rightsMask%)
  192.     If (rightsMask% And TR_SUPERVISOR) Then
  193.         rights$ = "S"
  194.     Else
  195.         rights$ = " "
  196.     End If
  197.  
  198.     If (rightsMask% And TR_MODIFY) Then
  199.         rights$ = rights$ + "M"
  200.     Else
  201.         rights$ = rights$ + " "
  202.     End If
  203.  
  204.     If (rightsMask% And TR_FILE) Then
  205.         If (IsV3Supported(connID%) = 1) Then
  206.             rights$ = rights$ + "F"
  207.         Else
  208.             rights$ = rights$ + "S"
  209.         End If
  210.     Else
  211.         rights$ = rights$ + " "
  212.     End If
  213.  
  214.     If (rightsMask% And TR_ACCESS) Then
  215.         If (IsV3Supported(connID%) = 1) Then
  216.             rights$ = rights$ + "A"
  217.         Else
  218.             rights$ = rights$ + "P"
  219.         End If
  220.     Else
  221.         rights$ = rights$ + " "
  222.     End If
  223.  
  224.     If (rightsMask% And TR_ERASE) Then
  225.         If (IsV3Supported(connID%) = 1) Then
  226.             rights$ = rights$ + "E"
  227.         Else
  228.             rights$ = rights$ + "D"
  229.         End If
  230.     Else
  231.         rights$ = rights$ + " "
  232.     End If
  233.  
  234.     If (rightsMask% And TR_CREATE) Then
  235.         rights$ = rights$ + "C"
  236.     Else
  237.         rights$ = rights$ + " "
  238.     End If
  239.  
  240.     If (IsV3Supported(connID%) <> 1) Then
  241.         If (rightsMask% And TA_OPEN) Then
  242.             rights$ = rights$ + "O"
  243.         Else
  244.             rights$ = rights$ + " "
  245.         End If
  246.     End If
  247.  
  248.     If (rightsMask% And TR_WRITE) Then
  249.         rights$ = rights$ + "W"
  250.     Else
  251.         rights$ = rights$ + " "
  252.     End If
  253.  
  254.     If (rightsMask% And TR_READ) Then
  255.         rights$ = rights$ + "R"
  256.     Else
  257.         rights$ = rights$ + " "
  258.     End If
  259.  
  260.     GetRights = rights$
  261. End Function
  262.  
  263. Sub OK